﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;
using GoodMan.Infrastructure.Entities.Enum;
using GoodMan.Infrastructure.Entities.Cache;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class ProductCategory : IAccessible<T_ProductCategory, ProductCategory>, ILogicEntity<T_ProductCategory, ProductCategory>
    {
        #region
        public int Id { get; set; }
        public string CategoryName { get; set; }
        public int ParentId { get; set; }
        public bool IsActive { get; set; }
        #endregion

        public List<ProductCategory> productCategorys { get; set; }

        public ProductCategory LoadProductCategorys(List<ProductCategory> productCategorys)
        {
            this.productCategorys = productCategorys;
            return this;
        }

        protected override void Covariant(T_ProductCategory model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.CategoryName = model.CategoryName;
                this.ParentId = model.ParentId;
                this.IsActive = model.IsActive;
            }
        }
        protected override T_ProductCategory Inverter(ProductCategory model)
        {
            if (model != null)
            {
                return new T_ProductCategory()
                {
                    Id = model.Id,
                    CategoryName = model.CategoryName,
                    ParentId = model.ParentId,
                    IsActive = model.IsActive
                };
            }
            return null;
        }
        public ProductCategory Set(T_ProductCategory dbModel)
        {
            Covariant(dbModel);
            return this;
        } 
    }
}
